package com.tian.controller.management;

import com.tian.common.CommonResult;
import com.tian.dto.*;
import com.tian.service.ChargeCouponService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * {@code @description:} 优惠券管理端操作
 *
 * @author tianwc 公众号：Java后端技术全栈
 * 在线刷题 1200+java面试题和1000+篇技术文章：<a href="https://woaijava.cc/">博客地址</a>
 * {@code @date:} 2024-08-05 22:49
 * {@code @version:} 1.0
 */
@RestController
@RequestMapping("/management/coupon")
@Api(tags = "优惠券 控制器")
public class ChargeCouponController {

    @Resource
    private ChargeCouponService chargeCouponService;

    @PostMapping("/add")
    public CommonResult<Boolean> add(@RequestBody ChargeCouponAddReqDto chargeCouponAddReqDto) {
        return chargeCouponService.add(chargeCouponAddReqDto);
    }

    @PostMapping("/delete")
    public CommonResult<Boolean> delete(@RequestBody ChargeCouponAddReqDto chargeCouponAddReqDto) {
        return chargeCouponService.delete(chargeCouponAddReqDto.getId());
    }


    @PostMapping("/start")
    public CommonResult<Boolean> start(@RequestBody ChargeCouponAddReqDto chargeCouponAddReqDto) {
        return chargeCouponService.start(chargeCouponAddReqDto.getId());
    }

    @PostMapping("/update")
    public CommonResult<Boolean> update(@RequestBody ChargeCouponUpdateReqDto chargeCouponUpdateReqDto) {
        return chargeCouponService.update(chargeCouponUpdateReqDto);
    }

    @PostMapping("/list")
    public CommonResult<BaseRespPageDto<List<ChargeCouponRespDto>>> list(@RequestBody ChargeCouponPageReqDto chargeCouponListReqDto) {
        return chargeCouponService.page(chargeCouponListReqDto);
    }
}
